package com.xyy.saas.payment.common.exception;


import com.xyy.saas.payment.cores.enums.ResultCodeEnum;
import com.xyy.saas.payment.cores.vo.ResultVO;

/**
 * @Author: wuqiongda
 * @Date: 2019/10/25 14:08
 */
public class PaymentException extends Exception {

    private static final long serialVersionUID = -3689430112581375179L;
    private String errCode;
    private String errMsg;
    private ResultCodeEnum codeEnum;

    private Object obj;

    public PaymentException() {
        super();
    }

    public PaymentException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getCode() + ":" + resultCodeEnum.getDisplayMsg());
        errCode = resultCodeEnum.getCode();
        errMsg = resultCodeEnum.getDisplayMsg();
        codeEnum = resultCodeEnum;
    }

    public PaymentException(ResultCodeEnum resultCodeEnum, String msg) {
        super(resultCodeEnum.getCode() + ":" + msg);
        errCode = resultCodeEnum.getCode();
        errMsg = msg;
        codeEnum = resultCodeEnum;
    }

    public PaymentException(ResultCodeEnum resultCodeEnum, Throwable cause) {
        super(resultCodeEnum.getCode() + ":" + resultCodeEnum.getMsg(), cause);
        errCode = resultCodeEnum.getCode();
        errMsg = resultCodeEnum.getMsg();
        codeEnum = resultCodeEnum;
    }

    public PaymentException(String message, Throwable cause) {
        super(message, cause);
    }

    public PaymentException(String message) {
        super(message);
    }

    public PaymentException(Throwable cause) {
        super(cause);
    }

    public PaymentException(String errCode, String errMsg, Throwable cause){
        super(errCode + ":" + errMsg, cause);
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public PaymentException(String errCode, String errMsg) {
        super(errCode + ":" + errMsg);
        this.errCode = errCode;
        this.errMsg = errMsg;
    }

    public String getErrCode() {
        return this.errCode;
    }

    public String getErrMsg() {
        return this.errMsg;
    }

    public ResultVO getResult() {
        return new ResultVO(errCode, errMsg);
    }

    public ResultCodeEnum getCodeEnum() {
        return codeEnum;
    }
}
